import request from '/@/api/request'

/** 分页获取工单列表 */
export const requestGetWorksheetListByPage = (data: GetWorksheetListByPage.IRequest) => {
  return request.post<IPaginationResponse<GetWorksheetListByPage.IResponse[]>>('/business/worksheet/getWorksheetListByPage', data)
}

/** 创建工单类型 */
export const requestSaveWorksheet = (data: SaveWorksheet.IRequest) => {
  return request.post<IBaseResponse<SaveWorksheet.IResponse[]>>('/business/worksheet/saveWorksheet', data)
}

/**  编辑工单类型 */
export const requestUpdateWorksheet = (data: UpdateWorksheetTypes.IRequest) => {
  return request.post<IBaseResponse<UpdateWorksheetTypes.IResponse[]>>('/business/worksheet/updateWorksheet', data)
}

/**  获取工单表单类型 */
export const requestGetBusinessDic = (data: GetBusinessDicTypes.IRequest) => {
  return request.post<IBaseResponse<GetBusinessDicTypes.IResponse[]>>('/business/worksheet/getBusinessDic', data)
}

/**  工单待办任务列表 */
export const requestActiveTaskByPage = (data: ActiveTaskTypes.IRequest) => {
  return request.post<IPaginationResponse<ActiveTaskTypes.IResponse[]>>('/business/worksheet/process/getActiveTaskByPage', data)
}

/**  工单已办任务列表 */
export const requestDownTaskByPage = (data: ActiveTaskTypes.IRequest) => {
  return request.post<IPaginationResponse<ActiveTaskTypes.IResponse[]>>('/business/worksheet/process/getDownTaskByPage', data)
}

/**  工单任务列表 */
export const requestTaskByPage = (data: ActiveTaskTypes.IRequest) => {
  return request.post<IPaginationResponse<ActiveTaskTypes.IResponse[]>>(`/business/worksheet/process/${data.worksheetRecordState === 1 ? 'getActiveTaskByPage' : 'getDownTaskByPage'}`, data)
}

/**  获取工单详情 */
export const requestTaskDetail = (data: TaskDetailTypes.IRequest) => {
  return request.post<IBaseResponse<TaskDetailTypes.IResponse>>('/business/worksheetRecord/getRecordById', data)
}

/**  获取工单审核详情 */
export const requestApproveInfo = (data: ApproveDetailTypes.IRequest) => {
  return request.post<IBaseResponse<ApproveDetailTypes.IResponse>>('/business/worksheet/process/getApproveInfo', data)
}

/**  任务审核通过 */
export const requestPassTask = (data: ApproveWorkTypes.IRequest) => {
  return request.post<IBaseResponse<ApproveWorkTypes.IResponse>>('/business/worksheet/process/approveTask', data)
}

/**  任务审核拒绝 */
export const requestRejectTask = (data: ApproveWorkTypes.IRequest) => {
  return request.post<IBaseResponse<ApproveWorkTypes.IResponse>>('/business/worksheet/process/rejectTask', data)
}
